<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>
        所有电梯
    </title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="../../../css/main.css" media="all">
    <script type="text/javascript" src="../../../lib/loading/okLoading.js"></script>
    <link rel="stylesheet" href="../../../css/bootstrap.css">
    <link rel="stylesheet" href="../../../lib/layui/css/layui_2.5.7.css">
    <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
    <style>
        .layui-table-page select {
            height: 22px;
        }
    </style>
</head>

<body>
<div id="app">
    <div class="x-nav">
        <span class="layui-breadcrumb">
            <a><cite>首页</cite></a>
            <a><cite>电梯信息</cite></a>
            <a><cite>电梯列表</cite></a>
        </span>
        <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
           href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon"
                                                                            style="line-height:30px">ဂ</i></a>
    </div>

    <div class="row">
        <div class="col-xs-6 col-sm-4 col-md-3">
            <section class="panel">
                <div class="symbol bgcolor-blue"><i class=" iconfont icon-dashaxiaoqudizhi01"></i>
                </div>
                <div class="value tab-menu" bind="1">
                    <a href="javascript:;" data-url="" data-parent="true" data-title="电梯总数"><i
                            class="iconfont " data-icon=""></i>
                        <h1>{{statistics.elevatorNum == null ? 0 : statistics.elevatorNum}}</h1>
                    </a>
                    <a href="javascript:;" data-url="" data-parent="true" data-title="电梯总数"> <i
                            class="iconfont " data-icon=""></i><span>电梯总数</span></a>
                </div>
            </section>
        </div>
        <div class="col-xs-6 col-sm-4 col-md-3">
            <section class="panel">
                <div class="symbol bgcolor-commred"><i class="iconfont icon-dashaxiaoqudizhi01"></i>
                </div>
                <div class="value tab-menu" bind="1">
                    <a href="javascript:;" data-url="" data-parent="true" data-title="正在保养"> <i
                            class="iconfont " data-icon=""></i>
                        <h1>{{statistics.matinNum == null ? 0 : statistics.matinNum}}</h1>
                    </a>

                    <a href="javascript:;" data-url="" data-parent="true" data-title="正在保养"> <i
                            class="iconfont " data-icon=""></i><span>正在保养</span></a>
                </div>
            </section>
        </div>
        <div class="col-xs-6 col-sm-4 col-md-3">
            <section class="panel">
                <div class="symbol bgcolor-orange"><i class="iconfont icon-dashaxiaoqudizhi01"></i>
                </div>
                <div class="value tab-menu" bind="1">
                    <a href="javascript:;" data-url="" data-parent="true" data-title="正在维修"> <i
                            class="iconfont " data-icon=""></i>
                        <h1>{{statistics.xiuNum == null ? 0 : statistics.xiuNum}}</h1>
                    </a>

                    <a href="javascript:;" data-url="" data-parent="true" data-title="正在维修"> <i
                            class="iconfont " data-icon=""></i><span>正在维修</span></a>
                </div>
            </section>
        </div>
        <div class="col-xs-6 col-sm-4 col-md-3">
            <section class="panel">
                <div class="symbol bgcolor-yellow"><i class="iconfont icon-dashaxiaoqudizhi01"></i>
                </div>
                <div class="value tab-menu" bind="1">
                    <a href="javascript:;" data-url="" data-parent="true" data-title="即将年检"> <i
                            class="iconfont " data-icon=""></i>
                        <h1>{{statistics.checkNum == null ? 0 : statistics.checkNum}}</h1>
                    </a>

                    <a href="javascript:;" data-url="" data-parent="true" data-title="即将年检"> <i
                            class="iconfont " data-icon=""></i><span>即将年检</span></a>
                </div>
            </section>
        </div>

    </div>

    <div class="main_box">
        <div class="panel-heading">
            <ul class="nav nav-tabs" id="navTabs">
                <li class="active"><a class="receivePane" data-tab="" href="elevator_list.html">所有电梯</a></li>
                <li class=""><a class="payPane" data-tab="" href="elevator_ewm.html">二维码</a></li>
                <li class=""><a class="borrowPane" data-tab="" href="elevator_maintenance_progress.html">正在保养</a></li>
                <li class=""><a class="borrowPane" data-tab="" href="elevator_under_repair.html">正在维修</a></li>
                <li class=""><a class="repayPane" data-tab="" href="elevator_contract_schedule.html">合同临期</a></li>
                <li class=""><a class="repayPane" data-tab="" href="elevator_expiration_of_contract.html">合同到期</a></li>
                <li class=""><a class="repayPane" data-tab="" href="elevator_coming_annual_inspection.html">即将年检</a></li>
                <li class=""><a class="repayPane" data-tab="" href="elevator_overdue_annual_inspection.html">年检超期</a></li>
                <li class=""><a class="repayPane" data-tab="" href="elevator_insurance_on_schedule.html">保险临期</a></li>
                <li class=""><a class="repayPane" data-tab="" href="elevator_parking_elevator.html">停保电梯</a></li>
            </ul>
        </div>
    </div>

    <form class="layui-form x-center">
        <div class="layui-form-pane" style="margin-top: 15px;" >
            <div class="layui-form-item">
                <label class="layui-form-label">使用证号</label>
                <div class="layui-input-inline">
                    <input  autocomplete="off"  type="text" class="layui-input" name="usenumber" id="usenumber" placeholder="使用证号">
                </div>
                <label class="layui-form-label">使用单位</label>
                <div class="layui-input-inline">
                    <select name="companyId" id="companyId" lay-filter="brickType">
                        <option value="">---</option>
                    </select>
                </div>
                <label class="layui-form-label">项目名称</label>
                <div class="layui-input-inline">
                    <select name="projectId" id="projectId" lay-search="">
                        <option value="">---</option>
                    </select>
                </div>
                <label class="layui-form-label">电梯位置</label>
                <div class="layui-input-inline">
                    <input  autocomplete="off"  type="text" class="layui-input" name="address" id="address" placeholder="电梯位置">
                </div>
                <label class="layui-form-label">电梯品牌</label>
                <div class="layui-input-inline">
                    <select name="brandId" id="brandId" lay-search="">
                        <option value="">---</option>
                    </select>
                </div>

                <hr>
                <label class="layui-form-label">维保人员</label>
                <div class="layui-input-inline">
                    <select name="mainuserId" id="mainuserId" lay-search="">
                        <option value="">---</option>
                    </select>
                </div>
                <label class="layui-form-label">电梯类型</label>
                <div class="layui-input-inline">
                    <select name="typeId" id="typeId" lay-search="">
                        <option value="">---</option>
                    </select>
                </div>
                <label class="layui-form-label">运行状态</label>
                <div class="layui-input-inline">
                    <select name="runtype" id="runtype" lay-search="">
                        <option value="">---</option>
                        <option value="0">正在运行</option>
                        <option value="1">已报修</option>
                        <option value="2">正在维修</option>
                        <option value="3">正在保养</option>
                        <option value="4">停止运行</option>
                    </select>
                </div>
                <label class="layui-form-label">停保</label>
                <div class="layui-input-inline">
                    <select name="isstopinsurance" id="isstopinsurance" lay-search="">
                        <option value="">---</option>
                        <option value="1">是</option>
                        <option value="0">否</option>
                    </select>
                </div>

                <hr>
                <div class="layui-form-item" id="area-picker">
                    <div class="layui-form-label">省市地区</div>
                    <div class="layui-input-inline" style="width: 200px;">
                        <select name="province" class="province-selector" lay-filter="province-1">
                            <option value="">请选择省</option>
                        </select>
                    </div>
                    <div class="layui-input-inline" style="width: 200px;">
                        <select name="city" class="city-selector" lay-filter="city-1">
                            <option value="">请选择市</option>
                        </select>
                    </div>
                    <div class="layui-input-inline" style="width: 200px;">
                        <select name="county" class="county-selector" lay-filter="county-1">
                            <option value="">请选择区</option>
                        </select>
                    </div>
                </div>
                <input  autocomplete="off"  type="hidden" name="areaString" id="areaString" >
                <label class="layui-form-label">添加时间</label>
                <div class="layui-input-inline">
                    <input  autocomplete="off"  class="layui-input" placeholder="开始日" name="starttime" id="starttime">
                </div>
                <div class="layui-input-inline">
                    <input  autocomplete="off"  class="layui-input" placeholder="截止日" name="endtime" id="endtime">
                </div>
                <div class="layui-input-inline layui-show-xs-block">
                    <button class="layui-btn" type="button" lay-filter="sreach" data-type="reload"
                            onclick="reload()">
                        <i class="layui-icon">&#xe615;</i></button>
                </div>

            </div>
        </div>
    </form>


    <div class="layui-card-body">
        <button style="float: right;" class="layui-btn" onclick="admin_add('添加信息','elevator_list_add.html','','700')"><i class="layui-icon"></i>添加
        </button>
        <table class="layui-table" id="test" lay-filter="test">
        </table>
    </div>
    <br><br><br><br><br><br>
</div>
</body>

<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="view">编辑</a>
    <a class="layui-btn layui-btn-xs" style="background: #673ab7" lay-event="cord">二维码</a>
    <a class="layui-btn layui-btn-xs" style="background: #f1a325" lay-event="baoxiu">报修</a>
    <a class="layui-btn layui-btn-xs" style="background: #db2f00;" lay-event="tingbao">停保</a>
    <a class="layui-btn layui-btn-xs" style="background: blue;" lay-event="plan">计划</a>
    <a class="layui-btn layui-btn-xs" style="background: #00F7DE;" lay-event="baoxian">保险</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" style="background: red;" lay-event="del">删除</a>
</script>


<script type="text/javascript" src="../../../js/jquery.min.js"></script>
<script type="text/javascript" src="../../../js/myAjax.js"></script>
<script type="text/javascript" src="../../../js/pub.js"></script>
<script type="text/javascript" src="../../../lib/layui/layui2.5.7.js"></script>
<script type="text/javascript" src="../../../js/vue.min.js"></script>
<!-- <script src="lib/layui/layui.js" charset="utf-8"></script> -->
<script src="../../../js/x-layui.js" charset="utf-8"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.3.5/js/bootstrap.min.js"></script>

<script>
    //配置插件目录
    layui.config({
        base: '../../../js/'
        , version: '1.0'
    });
</script>
<script>
    layui.use(['laydate', 'element', 'laypage', 'layer', 'form'], function () {
        $ = layui.jquery;//jquery
        laydate = layui.laydate;//日期插件
        lement = layui.element;//面包导航
        laypage = layui.laypage;//分页
        layer = layui.layer;//弹出层
        var form = layui.form;
        okLoading.close($);
    });
</script>


<script>

    layui.use(['laydate', 'form','layarea'],
        function () {
            var laydate = layui.laydate;
            var layarea = layui.layarea;


            //执行一个laydate实例
            laydate.render({
                trigger: 'click',
                type: 'date',
                elem: '#starttime' //指定元素
            });

            //执行一个laydate实例
            laydate.render({
                trigger: 'click',
                type: 'date',
                elem: '#endtime' //指定元素
            });

            layarea.render({
                elem: '#area-picker',
                // data: {
                //     province: '广东省',
                //     city: '深圳市',
                //     county: '龙岗区',
                // },
                change: function (res) {
                    //选择结果
                    console.log(res);
                    if(res.province!=""){
                        $("#areaString").val(res.province + "," + res.city + "," + res.county);
                    }else{
                        $("#areaString").val("");
                    }

                }
            });

            var form=layui.form;

            let request2 = {
                url: 'maintenance/company/findAll',
                method: "GET",
                data:{
                    userId:$userId,
                }
            };
            sendRequest(request2, (res) => {
                let x = res.data;
                $.each(x, function (index, item) {
                    let opt = $("<option value=" + item.id + ">" + item.name + "</option>");
                    $("#companyId").append(opt);
                });
                form.render('select');
            });

            let request3 = {
                url: 'maintenance/project/findAll',
                method: "GET",
                data:{
                    userId:$userId,
                }
            };
            sendRequest(request3, (res) => {
                let x = res.data;
                $.each(x, function (index, item) {
                    let opt = $("<option value=" + item.id + ">" + item.name + "</option>");
                    $("#projectId").append(opt);
                });
                form.render('select');
            });


            let request4 = {
                url: 'user/getMaintenanceUser',
                method: "GET",
                data:{
                    userId:$userId,
                }
            };
            sendRequest(request4, (res) => {
                let x = res;
                $.each(x, function (index, item) {
                    let opt = $("<option value=" + item.id + ">" + item.nickname + "</option>");
                    $("#mainuserId").append(opt);
                });
                form.render('select');
            });

            let request5 = {
                url: 'maintenance/elevatortype/gettypeData',
                method: "GET",
                data:{
                    userId:$userId,
                }
            };
            sendRequest(request5, (res) => {
                let x = res;
                $.each(x, function (index, item) {
                    let opt = $("<option value=" + item.id + ">" + item.name + "</option>");
                    $("#typeId").append(opt);
                });
                form.render('select');
            });


            let request6 = {
                url: 'maintenance/elevatorbrand/getbrandData',
                method: "GET",
                data:{
                    userId:$userId,
                }
            };
            sendRequest(request6, (res) => {
                let x = res;
                $.each(x, function (index, item) {
                    let opt = $("<option value=" + item.id + ">" + item.name + "</option>");
                    $("#brandId").append(opt);
                });
                form.render('select');
            });

            form.render('select');

            form.on('select(brickType)', function(data){

                let opthtml = $("<option value=''>请选择</option>");
                $("#projectId").html(opthtml);
                form.render('select');
                var val=data.value;
                if(val!=""){
                    let request = {
                        url: 'maintenance/project/findByCompanyId',
                        data: {
                            companyId: val,
                            userId:$userId,
                        },
                        method: "POST",
                    };
                    sendRequest(request, (res) => {
                        let x = res.data;
                        $.each(x, function (index, item) {
                            let opt = $("<option value=" + item.id + ">" + item.name + "</option>");
                            $("#projectId").append(opt);
                        });
                        form.render('select');
                    });
                }

            });

        });


    layui.use('table', function () {
        table = layui.table;
        //方法级渲染
        var t1 = table.render({
            elem: '#test',
            url: $baseUrl + 'maintenance/elevator/listAll',
            headers: {
                token: $token
            },where: {
                userId: $userId,
            }
            , toolbar: '#toolbarDemo',

            // toolbar: true,
            cols: [
                [
                    {
                        title: '使用单位',
                        fixed: 'left',
                        width: '100',
                        templet(item) {
                            return item.elevator.company.name== undefined ? "" : item.elevator.company.name;
                        }
                    },
                    {
                        title: '项目名称',
                        fixed: 'left',
                        width: '100',
                        templet(item) {
                            return item.elevator.project.name== undefined ? "" : item.elevator.project.name;
                        }
                    },

                    {
                        title: '电梯位置',
                        width: '350',
                        templet(item) {
                            return item.elevator.address== undefined ? "" : item.elevator.address;
                        }
                    },
                    {
                        title: '电梯类型',
                        width: '100',
                        templet(item) {
                            return item.elevator.type.name== undefined ? "" : item.elevator.type.name;
                        }
                    },
                    {
                        title: '安全管理人员',
                        width: '100',
                        templet(item) {
                            var person="";
                            $.each(item.adminList, function (index, itemadmin) {

                                var name = itemadmin+" ";
                                person +=name;
                            });
                            return person;
                        }
                    },

                    {
                        title: '维保人员',
                        width: '100',
                        templet(item) {
                            var person="";
                            $.each(item.userList, function (index, itemuser) {

                                var name = itemuser+" ";
                                person +=name;
                            });
                            return person;
                        }
                    },

                    {
                        title: '最近保养',
                        width: '100',
                        templet(item) {
                            return item.elevator.recentlymaintenanceDate== undefined ? "" : item.elevator.recentlymaintenanceDate;
                        }
                    },
                    {
                        title: '下次保养',
                        width: '100',
                        templet(item) {
                            return item.elevator.nextmaintenanceDate== undefined ? "" : item.elevator.nextmaintenanceDate;
                        }
                    },
                    {
                        title: '运行状态',
                        width: '100',
                        templet(item) {
                            if(item.elevator.runtype ==0){
                                return "正在运行";
                            }else if(item.elevator.runtype ==1){
                                return "已报修";
                            }
                            else if(item.elevator.runtype ==2){
                                return "正在维修";
                            }
                            else if(item.elevator.runtype ==3){
                                return "正在保养";
                            }
                            else if(item.elevator.runtype ==4){
                                return "停止运行";
                            }
                            else {
                                return "";
                            }
                        }
                    },

                    {
                        title: '停保',
                        templet(item) {
                            if(item.elevator.isstopinsurance ==0){
                                return "否";
                            }
                            else if(item.elevator.isstopinsurance ==1){
                                return "是";
                            }
                            else{
                                return "";
                            }
                        }
                    },
                    {
                        title: '使用证号',
                        width: '100',
                        templet(item) {
                            return item.elevator.usenumber== undefined ? "" : item.elevator.usenumber;
                        }
                    },

                    {
                        title: '省市地区',
                        width: '200',
                        templet(item) {
                            return item.elevator.project.areaString== undefined ? "" : item.elevator.project.areaString;
                        }
                    },
                    {

                        templet(item) {
                            return item.elevator.createTime== undefined ? "" : item.elevator.createTime;
                        },
                        title: '添加时间',
                        width: '100',

                    },

                    {
                        field: 'status',
                        title: '操作',
                        templet: '#barDemo',
                        fixed: 'right',
                        width: '380'
                    }]
            ],
            request: {
                pageName: 'pageNum', //页码的参数名称，默认：page
                limitName: 'pageSize',
            },
            response: {
                statusName: 'code' //规定数据状态的字段名称，默认：code
                ,
                statusCode: 0 //规定成功的状态码，默认：0
                ,
                msgName: 'msg' //规定状态信息的字段名称，默认：msg
                ,
                countName: 'total' //规定数据总数的字段名称，默认：count
                ,
                dataName: 'data', //规定数据列表的字段名称，默认：data
            },
            id: 'test',
            page: true,
            height: 'auto',
            even: true,
            done: function (res, curr, count) {
                //是否有权限或权限是否失效
                // authorizeState();
            }
        });

        //监听工具条
        table.on('tool(test)', function (obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
            let data = obj.data; //获得当前行数据
            let layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
            if (layEvent === 'del') { //删除
                layer.confirm('是否确认删除 ？', {
                    icon: 3,
                    title: '提示'
                }, function (index) {
                    let request = {
                        url: "maintenance/elevator/del/" + data.elevator.id,
                        data: {
                            userId: $userId,
                        },
                        method: "DELETE",
                    };
                    sendRequest(request, (data) => {
                        if (data.code === 0) {
                            layer.msg("删除成功", {
                                icon: 1
                            });
                            t1.reload();
                        } else {
                            layer.msg("删除失败，请稍后再试！", {
                                icon: 5
                            });
                        }
                    });
                    layer.close(index);
                });
            } else if (layEvent === 'view') { //编辑
                admin_add('电梯编辑', 'elevator_list_edit.html?recordId=' + data.elevator.id)
            }
            else if (layEvent === 'cord') { //二维码
                admin_add('电梯二维码', 'elevator_list_ewm.html?recordId=' + data.elevator.id)
            }
            else if (layEvent === 'tingbao') { //停保

                if(data.elevator.runtype !=0){
                    layer.msg("该电梯非正常运行状态！", {
                        icon: 5
                    });

                }else if(data.elevator.isstopinsurance ==1){
                    layer.msg("该电梯已停保！", {
                        icon: 5
                    });
                }else{
                    admin_add('电梯停保', 'elevator_stopinsurance.html?recordId=' + data.elevator.id)
                }

            }
            else if (layEvent === 'baoxiu') { //报修
                if(data.elevator.runtype ==0){
                    admin_add('电梯报修', 'elevator_repair.html?recordId=' + data.elevator.id)
                }else{
                    layer.msg("该电梯非正常运行状态！", {
                        icon: 5
                    });
                }
            }
            else if (layEvent === 'plan') { //计划
                if(data.elevator.runtype ==0){
                    admin_add('电梯计划', 'elevator_plan.html?recordId=' + data.elevator.id)
                }else{
                    layer.msg("该电梯非正常运行状态！", {
                        icon: 5
                    });
                }
            }
            else if (layEvent === 'baoxian') { //保险
                if(data.elevator.runtype ==0){
                    admin_add('电梯保险', 'elevator_Insurance.html?recordId=' + data.elevator.id)
                }else{
                    layer.msg("该电梯非正常运行状态！", {
                        icon: 5
                    });
                }
            }
        });

    });

    function reload(value) {
        table.reload('test', {
            where: {
                usenumber: $("#usenumber").val(),
                companyId: $("#companyId").val(),
                projectId: $("#projectId").val(),
                areaString: $("#areaString").val(),
                address: $("#address").val(),
                mainuserId: $("#mainuserId").val(),
                typeId: $("#typeId").val(),
                brandId: $("#brandId").val(),
                runtype: $("#runtype").val(),
                isstopinsurance: $("#isstopinsurance").val(),
                starttime: $("#starttime").val(),
                endtime: $("#endtime").val(),
            }
        });
    }

    function admin_add(title, url, w, h) {
        x_admin_show(title, url, w, h);
    }
</script>

<script>
    new Vue({
        el: "#app",
        data: {
            statistics: {
                elevatorNum: null,
                matinNum: null,
                xiuNum: null,
                checkNum: null,
            }
        },
        created() {
            let form = layui.form;
            let request = {
                url: 'maintenance/elevator/liststatisticstotal',
                method: "GET",
                data:{
                    userId:$userId,
                }
            };
            sendRequest(request, (res) => {
                this.statistics = res.data
            });


        }
    });

</script>


</html>
